package algorithms;


import com.fasterxml.jackson.databind.BeanProperty;
import edu.princeton.cs.algs4.ST;
import edu.princeton.cs.algs4.StdDraw;
import edu.princeton.cs.algs4.StdRandom;

/**
 * @功能
 * @创建时间 2020/6/7
 */
public class que1131 {
    public static void main(String[] args) {
    double x=50;
    double y=50;
    double r=50;
    int N=10;
    double p=0.2;
    double[][] a = new double[N][2];
    drawcricle(x,y,r,N,p,a);
    Randomline(x,y,a);

    }
    public static void drawcricle(double x,double y,double r,int N,double p,double[][] a){
        StdDraw.setXscale(0,x*2);
        StdDraw.setYscale(0,y*2);
        StdDraw.setPenRadius(0.005);
        StdDraw.setPenColor(StdDraw.RED);
        StdDraw.circle(50,50,50);
        for(int i=0;i<N;i++){
            StdDraw.setPenRadius(0.05);
            StdDraw.setPenColor(StdDraw.BLACK);
            double m = 50-50*Math.cos(2*Math.PI*i/N);
            double n = 50+50*Math.sin(2*Math.PI*i/N);
            StdDraw.point(m,n);
            a[i][0]=m;
            a[i][1]=n;
            StdDraw.setPenColor(StdDraw.RED);
        }
    }

    public static void Randomline(double x,double y,double[][] a){
        StdDraw.setXscale(0,x*2);
        StdDraw.setYscale(0,y*2);
        StdDraw.setPenRadius(0.01);
        StdDraw.setPenColor(StdDraw.LIGHT_GRAY);
        int N=a.length;
        for (int i=0;i<N;i++)
            for(int j=0;j<N;j++){
                if(StdRandom.bernoulli(0.5))
                    StdDraw.line(a[i][0],a[i][1],a[j][0],a[j][1]);
            }
    }
}
